package day2;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Test4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int page = in.nextInt();
            String mouse = in.next();
            char[] ch = mouse.toCharArray();

            if(page <= 4) {
                for(int i = 0; i < page; i++) {
                    System.out.print(i+1 + " ");
                }
                System.out.println();

                int pg = 1;
                for(int i = 0; i < ch.length; i++) {
                    if(ch[i] == 'U') {
                        pg = (pg-1) % page;
                        if(pg == 0) {
                            pg = page;
                        }
                    }else if(ch[i] == 'D') {
                        pg = (pg+1) % page;
                        if(pg == 0) {
                            pg = page;
                        }
                    }
                }
                System.out.println(pg);

            } else {
                int pg = 1;
                int[] pages = {1, 2, 3, 4};
                for(int i = 0; i < ch.length; i++) {
                    if(ch[i] == 'U') {
                        pg = (pg-1) % page;
                        if(pg == 0) {
                            pg = page;
                        }
                        if(pg < pages[0]){
                            for(int j = 0; j < 4; j++) { // aa
                                pages[j]--;
                            }
                        }
                        if(pg == page) {
                            for(int k = 0; k < 4; k++) {
                                pages[k] = (page-3)+k;
                            }
                        }
                    }else if(ch[i] == 'D') {
                        pg = (pg+1) % page;
                        if(pg == 0) {
                            pg = page;
                        }
                        if(pg > pages[3]){
                            for(int j = 0; j < 4; j++) {
                                pages[j]++;
                            }
                        }
                        if(pg == 1) {
                            for(int k = 0; k < 4; k++) { // aa
                                pages[k] = k+1;
                            }
                        }
                    }
                }


                for(int i = 0; i < pages.length; i++) {
                    System.out.print(pages[i] + " ");
                }
                System.out.println();
                System.out.println(pg);
            }
        }
    }
}
